package com.click369.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.click369.crm.mapper.CRoleMapper;
import com.click369.crm.pojo.CRole;
import com.click369.crm.service.RoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class RoleServiceImpl implements RoleService{
	
	@Autowired
	private CRoleMapper roleMapper;
	//添加
	@Override
	public void save(CRole role) {
		roleMapper.insert(role);
	}
	//根据id删除
	@Override
	public void delete(Integer id) {
		roleMapper.deleteByPrimaryKey(id);
	}
	//修改
	@Override
	public void update(CRole role) {
		roleMapper.updateByPrimaryKey(role);
	}
	//查询所有分页
	@Override
	public PageInfo<CRole> select(Integer page, Integer rows, CRole role) {
		//分页
		PageHelper.startPage(page,rows);
		List<CRole> list=roleMapper.select(role);
		return new PageInfo(list);
	}
	//根据id查询
	@Override
	public CRole getById(Integer id) {
		return roleMapper.selectByPrimaryKey(id);
	}
}
